package learning.directory.Work.排序.Ac;/**
 * Created by Administrator on 2021/2/22.
 */

import java.util.*;

/**
 * @author Administrator
 * @date 2021/2/22
 */
public class TestL {
    public static void main(String[] args) {
        List<List<String>> arr = new ArrayList<>();
        List<String> strList = new ArrayList<>();
        List<String> strList2 = new ArrayList<>();
        strList.add("张三");
        strList.add("张三2");
        strList.add("张三3");
        strList.add("张三4");
        strList2.add("李四");
        strList2.add("李四2");
        strList2.add("李四3");
        arr.add(strList);
        arr.add(strList2);
        System.out.println(Arrays.toString(arr.toArray()));
        randomValuesFromSomeArray(arr);

    }

    public static String randomValuesFromSomeArray(List<List<String>> arrList) {

        StringBuffer sb = new StringBuffer();
        Random random = new Random();

        for (int i = 0; i < arrList.size(); i++) {
            List<String> objList = arrList.get(i);
            if(sb.length()>0){
                sb.append("|");
            }
            sb.append(objList.get(random.nextInt(objList.size())));
        }

        return sb.length() >0 ? sb.substring(0, sb.length() - 1) : "";
    }
}
